package org.usmile.algorithms.huawei.acm;

import java.util.Scanner;

// https://blog.csdn.net/amos_cloud/article/details/129097193
public class _上班之路 {
    private static int t;
    private static int c;
    private static char[][] metric;
    private static boolean[][] visited;
    private static int rows;
    private static int cols;
    private static int[] beginPosition;
    private static final int[][] directions = new int[][]{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        t = sc.nextInt();
        c = sc.nextInt();
        sc.nextLine();
        rows = sc.nextInt();
        cols = sc.nextInt();
        sc.nextLine();
        metric = new char[rows][cols];
        visited = new boolean[rows][cols];
        for (int row = 0; row < rows; row++) {
            char[] rowLine = sc.nextLine().toCharArray();
            for (int col = 0; col < cols; col++) {
                metric[row][col] = rowLine[col];
                if (rowLine[col] == 'S') {
                    beginPosition = new int[]{row, col};
                }
            }
        }

        if (dfs(beginPosition[0], beginPosition[1], 0, 0, -1)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    private static boolean dfs(int row, int col, int tCount, int cCount, int direct) {
        if (tCount > t || cCount > c) {
            return false;
        }

        if (metric[row][col] == 'T') {
            return true;
        }

        visited[row][col] = true;
        for (int i = 0; i < directions.length; i++) {
            int nextRow = row + directions[i][0];
            int nextCol = col + directions[i][1];
            if (nextRow >= 0 && nextRow < rows && nextCol >= 0 && nextCol < cols) {
                if (!visited[nextRow][nextCol]) {
                    boolean turn = direct != -1 && i != direct;
                    boolean move = metric[nextRow][nextCol] == '*';
                    if (dfs(nextRow, nextCol, turn ? tCount + 1 : tCount, move ? cCount + 1 : cCount, i)) {
                        return true;
                    }
                }
            }
        }
        visited[row][col] = false;

        return false;
    }
}
